package com.huabo.contract.mysql.mapper;

import com.hbfk.util.PageInfo;
import com.huabo.contract.mysql.entity.TblContractAppendixsigningMySql;

public class TblContractAppendixsigningMySqlMapperSqlConifg {
	public String findFileListByContractIdPageInfo(PageInfo<TblContractAppendixsigningMySql> pageInfo) throws Exception {
		TblContractAppendixsigningMySql tca = pageInfo.getCondition();
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (SELECT TAC.SINGINGID,TAC.SINGINGNAME,TAC.SINGINGPATH,TAC.SINGINGSIZE,TAC.SINGINGTYPE,TAC.SINGINGSTATUS,TAC.CONSTRACTID,TAC.UPLOADTIME,TAC.UPLOADER,TS.REALNAME FROM TBL_CONTRACT_APPENDIXSIGNING TAC LEFT JOIN TBL_STAFF TS ON TAC.UPLOADER = TS.STAFFID WHERE TAC.CONSTRACTID = " + tca.getConstractId());
		if (tca.getSingingName() != null && !"".equals(tca.getSingingName())) {
			sqlSb.append(" AND TAC.SINGINGNAME LIKE '%" + tca.getSingingName() + "%'");
		}
		sqlSb.append(" ORDER BY TAC.UPLOADER) BUDGET WHERE rownum <= "+(pageInfo.getCurrentPage()*pageInfo.getPageSize())+" ) WHERE RN > "+pageInfo.getCurrentRecord());
		String sql = sqlSb.toString();
		return sql;
	}

	public String findCountFileListByContractIdPageInfo(PageInfo<TblContractAppendixsigningMySql> pageInfo) throws Exception {
		TblContractAppendixsigningMySql tca = pageInfo.getCondition();
		StringBuffer sqlSb = new StringBuffer("SELECT COUNT(*) FROM TBL_CONTRACT_APPENDIXSIGNING TAC LEFT JOIN TBL_STAFF TS ON TAC.UPLOADER = TS.STAFFID WHERE TAC.CONSTRACTID = " + tca.getConstractId());
		if (tca.getSingingName() != null && !"".equals(tca.getSingingName())) {
			sqlSb.append(" AND TAC.SINGINGNAME LIKE '%" + tca.getSingingName() + "%'");
		}
		return sqlSb.toString();
	}


}
